package thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description: Executor的使用
 * User: 王圆豪
 * Date: 2025-05-03
 * Time: 21:25
 */
public class Demo29 {
    public static void main(String[] args) {
        ExecutorService pool1 = Executors.newFixedThreadPool(5);
//        ExecutorService pool2 = Executors.newCachedThreadPool();
        for (int i = 0; i < 100; i++) {
            int id = i;
            pool1.submit(()->{
                System.out.println(Thread.currentThread().getName() + "正在执行任务" + id);
            });
        }
    }
}
